VERSION 5.00
Begin VB.Form frmDelete 
   BackColor       =   &H00FFFFFF&
   Caption         =   "Delete Package"
   ClientHeight    =   1440
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5790
   Icon            =   "frmDelete.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   1440
   ScaleWidth      =   5790
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdClose 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "OK"
      Height          =   315
      Left            =   2280
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   960
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdSubmitDelete 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Submit"
      Height          =   315
      Left            =   4080
      MaskColor       =   &H00E0E0E0&
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   480
      Width           =   855
   End
   Begin VB.TextBox f29 
      BackColor       =   &H00FFFFFF&
      Height          =   315
      Left            =   1680
      TabIndex        =   0
      Top             =   480
      Width           =   2175
   End
   Begin VB.Label lbl29 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "Tracking #:"
      Height          =   255
      Left            =   600
      TabIndex        =   3
      Top             =   540
      Width           =   975
   End
   Begin VB.Label Label68 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Delete Package"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   255
      Left            =   360
      TabIndex        =   2
      Top             =   135
      Width           =   2775
   End
   Begin VB.Line Line24 
      BorderColor     =   &H000080FF&
      BorderWidth     =   2
      X1              =   360
      X2              =   5400
      Y1              =   120
      Y2              =   120
   End
End
Attribute VB_Name = "frmDelete"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'---------------------------------------------------------------------------------------
' Procedure : cmdClose_Click()
' DateTime  : 3/25/2004
' Purpose   : Close button clicked, hide form
'---------------------------------------------------------------------------------------
'
Private Sub cmdClose_Click()
    Call frmShip.EnableButtons
    Me.Hide
    If frmShip.Visible Then frmShip.SetFocus
End Sub

Private Sub Form_Activate()
    f29.SetFocus
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Load()
' DateTime  : 3/25/2004
' Purpose   : Highlight the tracking # field
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()
    f29.BackColor = &HC0E0FF
End Sub
'---------------------------------------------------------------------------------------
' Procedure : f29_Change()
' DateTime  : 3/16/2004
' Purpose   : Tracking number field on Shipped List tab used for deleting. Numeric only
'---------------------------------------------------------------------------------------
'
Private Sub f29_Change()
    f29.BackColor = &HFFFFFF
    Call NumericOnly(f29, False)
End Sub

'---------------------------------------------------------------------------------------
' Procedure : cmdSubmitDelete_Click()
' DateTime  : 2/18/2004
' Purpose   : Calls BuildDeleteTrans to delete a trk#, parses out trk# if Ground or ASTRA bacodes
'             are scanned into the field
'---------------------------------------------------------------------------------------
'
Private Sub cmdSubmitDelete_Click()
    Dim rsIPD As New ADODB.Recordset
    Dim strQuery As String
    
    'Exit sub if blank, else update status message
    If f29 = "" Then
        Exit Sub
    Else
        frmShip.StatusBar1.Panels(2) = "Deleting..."
    End If

    'Extracts trk# from a ASTRA barcode scanned into the f29 field
    If Len(f29) = 32 And (Left(f29, 1) = "3" Or Left(f29, 1) = "4") Then
        f29 = Mid(f29, 17, 12)
    End If
    'Extracts trk# from a FedEx Ground barcode scanned into the f29 field
    If Len(f29) = 22 And Left(f29, 2) = "96" Then
        f29 = Right(f29, 15)
    End If
    g_str29 = f29
    'Extracts the pkgID from a SmartPost Del Confirm Barcode
    If Len(f29) = 30 Then
        f29 = Right(f29, 20)
    End If
    '************************************************************************************
    'This section was added to check for an IPD CRN Trk#. If found in the IPD table send
    'a CRN Delete trans and exit the sub.
    strQuery = "SELECT g_str29, g_str1355, g_str50 FROM IPD WHERE MAWB = 0"
    rsIPD.Open strQuery, g_connFSMSClient, adOpenKeyset, adLockOptimistic
    
    Do Until rsIPD.EOF
        If g_str29 = rsIPD!g_str29 Then
            Call SendData(BuildCRNDeleteTrans(g_str29, rsIPD!g_str1355, rsIPD!g_str50))
            Exit Sub
        End If
        rsIPD.MoveNext
    Loop
    '************************************************************************************
    If Len(f29) = 20 Then
        Dim intRet As Integer
        
        intRet = DeleteSPPkg(f29)
        With frmShip
            Select Case intRet
                Case 0
                    If g_str3 <> "" Then
                        .StatusBar1.Panels(2) = g_str3
                    Else
                        .StatusBar1.Panels(2) = f29 & " Deleted!"
                    End If
                    Call WriteDelete(f29)
                Case 1
                    ' MsgBox f29 & " has already been deleted.", vbExclamation, "Delete Error"
                    .StatusBar1.Panels(2) = f29 & " Already deleted!"
                    Call WriteDelete(f29)
                Case 2
                    MsgBox f29 & " has already been manifested.", vbExclamation, "Delete Error"
                    .StatusBar1.Panels(2) = "Deleted Error!"
                Case 3
                    MsgBox f29 & " not found.", vbExclamation, "Delete Error"
                    .StatusBar1.Panels(2) = "Deleted Error!"
            End Select
        End With
    Else
        Call SendData(BuildDeleteTrans(f29))
    End If
End Sub

